home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11166 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: news.sinet.slb.com!usenet
  2. From: "Vinh D. Nguyen" <vnguyen@sugar-land.anadrill.slb.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Q: default copy constructor
  5. Date: Tue, 12 Mar 1996 18:03:19 -0600
  6. Organization: Schlumberger Anadrill
  7. Message-ID: <314610C7.5BB4@sugar-land.anadrill.slb.com>
  8. References: <4i49tj$991@azure.acsu.buffalo.edu>
  9. NNTP-Posting-Host: 163.185.118.40
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (WinNT; I)
  14.  
  15. Li Chen wrote:
  16. > Hi, everyone:
  17. > Ihave a question:does a C++ compiler generate copy constructor
  18. > if there is none in the program?
  19. > Thank you.
  20. > David
  21. > --
  22. > ___________________________________________________________________________
  23. > ---------------------------------------------------------------------------
  24. > David Li Chen
  25.  
  26. Yes, but the compiler will generate only a shallow copy constructor. That is,
  27. suppose A contains a pointer to C, after B = A, B points to the same C object.
  28. This may create a problem because if A destroys C upon its own destruction
  29. then B would point to an object that no longer exists.
  30.  
  31. -- 
  32. --------------------------------------------------------------------------
  33. * Vinh Nguyen                                            vnguyen@slb.com *
  34. * Drilling Information Products - Senior Engineer                        *
  35. * Anadrill Schlumberger                             *
  36. * 200 Gillingham Ln.                             (713) 275-7524 (Office) *
  37. * Sugarland, TX 77478                            (713) 275-8098 (FAX)    *
  38. --------------------------------------------------------------------------
  39.